﻿using System;

namespace diantou.web.enterprise
{
    /// <summary>
    /// 题目编辑
    /// </summary>
    abstract class questionEdit<viewType> : examPermissionView<viewType>
        where viewType : questionEdit<viewType>
    {
        /// <summary>
        /// 题目
        /// </summary>
        [fastCSharp.emit.webView.clearMember]
        protected diantou.examDataAccess.examQuestion question;
        /// <summary>
        /// 考试类型
        /// </summary>
        protected abstract dataModel.examQuestion.type type { get; }
        /// <summary>
        /// 是否修改描述
        /// </summary>
        protected bool isReworkDescription
        {
            get { return question.Id == 0; }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="questionId"></param>
        /// <returns></returns>
        protected bool loadView(int questionId)
        {
            if (questionId == 0)
            {
                question = diantou.examDataAccess.examQuestion.NullQuestion;
                return true;
            }
            else
            {
                question = examDataAccess.clientCache.ExamQuestion[questionId];
                if (question != null)
                {
                    if (question.IsExamEditor(currentUser)) return true;
                    question = null;
                }
            }
            AjaxResponse(new fastCSharp.code.cSharp.webView.errorPath { ErrorPath = diantou.dataModel.path.pub.EnterpriseLogin });
            return false;
        }
    }
}
